package net.imain.cloud.controller;

import net.imain.cloud.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;

/**
 * @author: uncle
 * @apdateTime: 2017-12-09 18:41
 */
@RestController
@RequestMapping(value = "/movie/")
public class MovieController {

    @Autowired
    private RestTemplate restTemplate;

    @Value("${user.userServicePath}")
    private String userServicePath;

    @GetMapping(value = "/{id}")
    public User findById(@PathVariable(value = "id") Long id) {
        // 消费另外一个微服务的API
        return restTemplate.getForObject(userServicePath + id, User.class);
    }
}
